/*************************************************
Author: byron
Date: 11/03/2012
Description:
Notes: 
*************************************************/

#ifndef __CSkillEffect_h__
#define __CSkillEffect_h__

#include "commclass.h"

class CSkillEffect
{
public:
    enum SKILL_STAT_TYPE_TAG
    {
        SKILL_STAT_REMOVE_MAIN              = 1,            //驱散主效果 
        SKILL_STAT_REMOVE_SUB               = 2,            //驱散子效果 需要将Subtype填在Data处
        SKILL_STAT_IMMUNE_MAIN              = 3,            //免疫主效果 
        SKILL_STAT_IMMUNE_SUB               = 4,            //免疫子效果 需要将Subtype填在Data处
        SKILL_STAT_PRE_CASTER               = 5,            //预处理施法者
        SKILL_STAT_PRE_TARGET               = 6,            //预处理受击者
        SKILL_STAT_SWIM                     = 7,            //晕眩
        SKILL_STAT_STICK                    = 8,            //定身
        SKILL_STAT_HITBACK                  = 9,            //击飞
        SKILL_STAT_PULL                     = 10,           //拖拽
        SKILL_STAT_MODIFY                   = 11,           //修正个体消耗型属性(勇气、怒气、血量等)
        SKILL_STAT_BUFF_HOT                 = 12,           //HOT 加血
        SKILL_STAT_BUFF_DOT                 = 13,           //DOT 减血
        SKILL_STAT_BUFF_1                   = 14,           //BUFF类型1
        SKILL_STAT_DEBUFF_1                 = 15,           //DEBUFF类型1
        SKILL_STAT_BUFF_2                   = 16,           //BUFF类型2
        SKILL_STAT_DEBUFF_2                 = 17,           //DEBUFF类型2
        SKILL_STAT_BUFF_3                   = 18,           //BUFF类型3
        SKILL_STAT_DEBUFF_3                 = 19,           //DEBUFF类型3
        SKILL_STAT_REVISE_VAL               = 20,           //修正战斗结算数值
        SKILL_STAT_AMEND_ATTR               = 21,           //修正个体二级属性
        SKILL_STAT_RANDOM                   = 22,           //产生一个随机数
        SKILL_STAT_GROUP_CMD_START          = 23,           //输出组合命令开启
        SKILL_STAT_GROUP_CMD_STOP           = 24,           //输出组合命令关闭
        SKILL_STAT_FRONT_EFF_VIDEO          = 25,           //输出Buff增加方便前端展示后端不处理
        SKILL_STAT_FRONT_DIE_VIDEO          = 26,           //输出主角死亡方便前端展示后端不处理
        SKILL_STAT_FRONT_WAIT_VIDEO         = 27,           //输出主角等待方便前端展示后端不处理
        SKILL_STAT_SHIELD                   = 28,           //护盾
        SKILL_STAT_AMEND_ATTR_TURN          = 29,           //修正个体二级属性只是当前回合有效
        SKILL_STAT_BUFF_TREASURE            = 30,           //秘宝产生的过程性效果
        SKILL_STAT_BUFF_MOUNT               = 31,           //坐骑产生的过程性效果
        SKILL_STAT_DEAD_KILL                = 32,           //斩杀效果
    };

    enum SKILL_STAT_SUBTYPE_TAG            //值保持与角色二级属性枚举一致
    {
        SKILL_SUB_STAT_COURAGE              = 1,         //勇气
        SKILL_SUB_STAT_ANGER                = 2,         //怒气
        SKILL_SUB_STAT_DISTANCE             = 3,         //站位距离
        SKILL_SUB_STAT_REVISE               = 4,         //下一次行动开始且整个战斗都生效的修正伤害
        SKILL_SUB_STAT_REVISE_VAL           = 5,         //自身攻击时生效的修正伤害 多用在持续性Buff
        //注意 SKILL_SUB_STAT_HP = EXT_ATTR_HP 值为 6
        SKILL_SUB_STAT_HP                   = EXT_ATTR_HP,                  //生命
        SKILL_SUB_STAT_PHY_ATK              = EXT_ATTR_PHY_ATK,             //物攻
        SKILL_SUB_STAT_PHY_DEF              = EXT_ATTR_PHY_DEF,             //物防
        SKILL_SUB_STAT_MAG_ATK              = EXT_ATTR_MAG_ATK,             //魔攻
        SKILL_SUB_STAT_MAG_DEF              = EXT_ATTR_MAG_DEF,             //魔防
        SKILL_SUB_STAT_EARTH_ATK            = EXT_ATTR_EARTH_ATK,           //地攻
        SKILL_SUB_STAT_WIND_ATK             = EXT_ATTR_WIND_ATK,            //风攻
        SKILL_SUB_STAT_FIRE_ATK             = EXT_ATTR_FIRE_ATK,            //火攻
        SKILL_SUB_STAT_WATER_ATK            = EXT_ATTR_WATER_ATK,           //水攻
        SKILL_SUB_STAT_HIT                  = EXT_ATTR_HIT,                 //命中
        SKILL_SUB_STAT_DODGE                = EXT_ATTR_DODGE,               //闪避
        SKILL_SUB_STAT_DOUBLE               = EXT_ATTR_DOUBLE,              //暴击
        SKILL_SUB_STAT_ANTI_DOUBLE          = EXT_ATTR_ANTI_DOUBLE,         //抗暴
        SKILL_SUB_STAT_BLOCK                = EXT_ATTR_BLOCK,               //格挡
        SKILL_SUB_STAT_ANTI_BLOCK           = EXT_ATTR_ANTI_BLOCK,          //破击
        SKILL_SUB_STAT_CRIT                 = EXT_ATTR_CRIT,                //必杀
        SKILL_SUB_STAT_IMMUNE_INJURY        = EXT_ATTR_IMMUNE_INJURY,       //免伤
        SKILL_SUB_STAT_REACT_INJURY         = EXT_ATTR_REACT_INJURY,        //反伤
        SKILL_SUB_STAT_PENETRATE            = EXT_ATTR_PENETRATE,           //穿透
        SKILL_SUB_STAT_TREATMENT            = EXT_ATTR_TREATMENT,           //痊愈
        SKILL_SUB_STAT_FIGHT_BACK           = EXT_ATTR_FIGHT_BACK,          //反击
        SKILL_SUB_STAT_ACT_ANGER            = EXT_ATTR_ACT_ANGER,           //出场怒气

        SKILL_SUB_STAT_EXEC_AFFECT          = 36,         //为SKILL_STAT_RANDOM添加 继续执行SkillAffect
        SKILL_SUB_STAT_REVISE_OBJECT        = 37,         //只是当回合生效的伤害修正 aux_data特定目标
    };

    enum SKILL_STAT_VAL_TYPE_TAG
    {
        //注意以下计算结果会根据正负性加入痊愈或者免伤计算
        SKILL_STAT_VAL_NUM = 1,              //数值
        SKILL_STAT_VAL_RATE = 2,             //比值
        SKILL_STAT_VAL_RATE_OTHER_MAX_HP = 3,       //以目标者生命上限为基准的比值
        SKILL_STAT_VAL_RATE_OTHER_BEFORE_HP = 4,    //以目标者被击前生命为基准的比值
        SKILL_STAT_VAL_RATE_OTHER_NOW_HP = 5,       //以目标者当前生命为基准的比值
    };

    CSkillEffect()
    {
        //如果ID为非正数 则这个技能效果无效
        Clear();
    }

    virtual ~CSkillEffect() 
    {
    }

    void Clear()
    {
        _ucStatType = 0;
        _ucSubType = 0;
        _uiID = 0;
        _iTriggerRate = 0;
        _iType = 0;
        _iData = 0;
        _iLast = 0;
        _iAuxData = 0;
    }

    CSkillEffect& operator=(const CSkillEffect& stSkillEffect)
    {
        _ucStatType = stSkillEffect._ucStatType;
        _ucSubType = stSkillEffect._ucSubType;
        _uiID = stSkillEffect._uiID;
        _iTriggerRate = stSkillEffect._iTriggerRate;
        _iType = stSkillEffect._iType;
        _iData = stSkillEffect._iData;
        _iLast = stSkillEffect._iLast;
        _iAuxData = stSkillEffect._iAuxData;

        return *this;
    }

    bool IsValidID() const {return (_uiID > 0);}

    unsigned char GetStatType() const { return _ucStatType;}
    unsigned char GetSubType() const { return _ucSubType;}
    unsigned int GetID() const { return _uiID;}
    int GetTriggerRate() const {return _iTriggerRate;}
    int GetType() const {return _iType;}
    int GetData() const { return _iData;}
    int GetLastTurnCount() const {return _iLast;}
    int GetAuxData() const { return _iAuxData;}

    void SetStatType(unsigned char ucStatType){_ucStatType = ucStatType;}
    void SetSubType(unsigned char ucSubType){_ucSubType = ucSubType;}
    void SetID(unsigned int uiID){_uiID = uiID;}
    void SetTriggerRate(int iTriggerRate){_iTriggerRate = iTriggerRate;}
    void SetType(int iType){_iType = iType;}
    void SetData(int iData){_iData = iData;}
    void SetLast(int iLast){_iLast = iLast;}
    void SetAuxData(int iAuxData){_iAuxData = iAuxData;}

    //晕眩
    bool IsSwim() const { return (_ucStatType == SKILL_STAT_SWIM);}
    //定身
    bool IsStick() const { return (_ucStatType == SKILL_STAT_STICK);}
    //击飞
    bool IsHitBack() const {return (_ucStatType == SKILL_STAT_HITBACK);}
    //拖拽
    bool IsPull() const {return (_ucStatType == SKILL_STAT_PULL);}
    //护盾
    bool IsShield() const {return (_ucStatType == SKILL_STAT_SHIELD);}

    bool IsDefType(int iType) const {return (_iType == iType);}

    void DumpSkillEffectInfo();

private:
    unsigned char       _ucStatType;
    unsigned char       _ucSubType;
    unsigned int        _uiID;
    int                 _iTriggerRate;      //生效几率
    int                 _iType;             //数值类型
    int                 _iData;             //数值
    int                 _iLast;             //持续回合数
    int                 _iAuxData;          //辅助数据
};

#endif // __CSkillEffect_h__

